<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>Tables - Ace Admin</title>

<meta name="description" content="Static &amp; Dynamic Tables" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

<!-- bootstrap & fontawesome -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/bootstrap.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/font-awesome.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/bootstrap-datepicker3.min.css" />
	<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/bootstrap-timepicker.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/daterangepicker.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/bootstrap-datetimepicker.min.css" />
<!-- page specific plugin styles -->

<!-- text fonts -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace-fonts.css" />

<!-- ace styles -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace.min.css"
	id="main-ace-style" />

<!--[if lte IE 9]>
			<link rel="stylesheet" href="<%=request.getContextPath()%>/ace/assets/css/ace-part2.min.css" />
		<![endif]-->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace-skins.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace-rtl.min.css" />

<!--[if lte IE 9]>
		  <link rel="stylesheet" href="<%=request.getContextPath()%>/ace/assets/css/ace-ie.min.css" />
		<![endif]-->

<!-- inline styles related to this page -->

<!-- ace settings handler -->
<script
	src="<%=request.getContextPath()%>/ace/assets/js/ace-extra.min.js"></script>

<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

<!--[if lte IE 8]>
		<script src="<%=request.getContextPath()%>/ace/assets/js/html5shiv.min.js"></script>
		<script src="<%=request.getContextPath()%>/ace/assets/js/respond.min.js"></script>
		<![endif]-->
	<style>  
.black_overlay{  
 display: none;  
 position: absolute;  
 top: 80%;  
 left: 80%;  
 width: 100%;  
 height: 100%;  
 background-color: black;  
 z-index:1001;  
 -moz-opacity: 0.8;  
 opacity:.80;  
 filter: alpha(opacity=80);  
}  
.white_content {  
 display: none;  
 position: absolute;  
 top: 1%;  
 left: 40%;  
 width: 10%;  
 height: 8%;  
 color:#FF7F50;
 z-index:1002;  
 overflow: auto;  
}  
.white_content_small {  
 display: none;  
 position: absolute;  
 top: 80%;  
 left: 80%;  
 width: 5%;  
 height: 5%;  
 border: 16px solid lightblue;  
 background-color: white;  
 z-index:1002;  
 overflow: auto;  
}  
</style>  
<script type="text/javascript">  
//弹出隐藏层  
function ShowDiv(show_div,bg_div){  
 document.getElementById(show_div).style.display='block';  
 //document.getElementById(bg_div).style.display='block' ;  
 var bgdiv = document.getElementById(bg_div);  
 bgdiv.style.width = document.body.scrollWidth;   
 // bgdiv.style.height = $(document).height();  
 $("#"+bg_div).height($(document).height());
 setTimeout("document.getElementById('MyDiv').style.display='none'",3000);
};  
  
</script>  
</head>

<body class="no-skin" onload="toList()">
<c:if test="${not empty msg}">
    	<div id="myAlert" class="alert alert-warning">
			<a href="#" class="close" data-dismiss="alert">&times;</a>
			<strong>警告！</strong>${msg }。
		</div>
	</c:if>

<div id="fade" class="black_overlay">  
</div>  
 <div id="MyDiv" class="white_content">
 <div style="text-align: center;">
	警告!
	<div id="pp"></div>
 </div>

 </div>  
<div class="breadcrumbs" id="breadcrumbs">

		<ul class="breadcrumb">
			<li><i class="ace-icon fa fa-home home-icon"></i> <a >当前位置</a>
			</li>

			<li><a href="" onclick="lists()">产品服务列表</a></li>
			
		</ul>
		

	</div>
	<div class="page-content">
		<!-- /section:settings.box -->
		<div class="page-content-area">
			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->
					<div class="row">
						<div class="col-xs-12">
							<div class="table-header">产品服务管理</div>

							<!-- <div class="dataTables_borderWrap"> -->
							<div>
								<div id="sample-table-2_wrapper"
									class="dataTables_wrapper form-inline no-footer">
									<form action="<%=request.getContextPath()%>/bsbFirmProduct/list.do"
										method="get" id="drizzt-table">
										<input type="hidden" name="uuid" value="" id="uuid"/>
										<div class="row">
											<div class="col-xs-2">
												<table cellspacing="0" cellpadding="0" border="0"
													style="float: left; table-layout: auto;"
													class="ui-pg-table navtable">
													<tbody>
														<tr>
															<td class="ui-pg-button ui-corner-all" title=""
																id="add_grid-table" data-original-title="Add new row"><div
																	class="ui-pg-div">
																	 <shiro:hasPermission name="bsbFirmProduct:add">
																	<input type="button" class="btn btn-sm btn-primary" onclick="goOperate('add')" value="新增" />
																	</shiro:hasPermission>
																</div></td>
															<td>&nbsp;&nbsp;</td>
															
															
														</tr>
													</tbody>
												</table>
											</div>
											<div class="col-xs-10">
												<div class="input-group input-group-sm">
												
										            <span class="input-group-addon">标题</span>
										            <input type="text" class="form-control" name="name" value="${name }"  placeholder="产品标题">
										        </div>
												
												<div class="input-group input-group-sm">
												&nbsp;
										            <span class="input-group-addon">状态</span>
										            <select class="form-control" name="delflag">
												      <option value="">全部</option>
												      <option value="0" <c:if test="${delflag=='0' }">selected</c:if> >显示</option>
												      <option value="1" <c:if test="${delflag=='1' }">selected</c:if> >隐藏</option>
												    </select>
										        </div>
										        <div class="input-group input-group-sm">
										        &nbsp;
										        	<span class="input-group-addon">发布日期</span>
													<div class="input-daterange" data-date-format="yyyy-mm-dd" id="datepicker">
													    <input type="text" class="input-sm form-control" name="start" placeholder="起始日期" value="${start }"/>
													    <span class="">--</span>
													    <input type="text" class="input-sm form-control" name="end" placeholder="截止日期" value="${end }"/>
													</div>
										        </div>
												<button type="button" onclick="search()" class="btn btn-purple btn-sm" style="vertical-align:top;">
													<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
													搜索
												</button>
											</div>
										</div>
										<table
										 
											class="table table-striped table-bordered table-hover dataTable no-footer"
											id="sample-table-2" role="grid"
											aria-describedby="sample-table-2_info">
											<thead align="center">
												<tr role="row"  class="center"  >
														<th width="35%"  class="sorting_disabled center" >产品标题</th>
														<th width="10%" class="sorting_disabled center">金额</th>
														<th width="10%" class="sorting_disabled center">封面</th>
														<th width="5%" class="sorting_disabled center">排序</th>
														<th width="15%" class="sorting_disabled center">发布日期</th>
														<th width="5%" class="sorting_disabled center">状态</th>
														<th width="20%" class="sorting_disabled center">操作</th>
												</tr>
											</thead>

											<tbody class="tbody">
												<%-- <c:forEach items='${bsbFirmProducts}' var="bsbFirmProduct">
													<tr role="row" class="odd" align="center">
															<td class="center"><label class="position-relative">
															<input id="uuid" name="uuid" type="radio" value="${bsbFirmProduct.uuid}" class="ace" /> <span
															class="lbl"></span>
															</label></td>
															<td>${bsbFirmProduct.title}</td>
															<td>${bsbFirmProduct.price==0?"面议":bsbFirmProduct.price}</td>
															<td>
															<img alt="" width="30px" height="30px" <c:if test="${not empty bsbFirmProduct.logImg}">src='<%=request.getContextPath()%>/getPic/${bsbFirmProduct.logImg}'</c:if>> 
															</td>
															<td>${bsbFirmProduct.sort}</td>
															<td>
															<fmt:formatDate pattern="yyyy/MM/dd HH:mm:dd" value="${bsbFirmProduct.createDate}" />
															</td>
															<td>${bsbFirmProduct.delFlag=='0'?"显示":"隐藏"}</td>
															<td>
										                    <shiro:hasPermission name="bsbFirm:view">
										                        <a class="blue"  href="<%=request.getContextPath()%>/bsbFirm/${bsbFirmProduct.uuid}/view">
																	<i class="ace-icon fa fa-search-plus bigger-130"></i>查看
																</a>
										                    </shiro:hasPermission>
										                    <shiro:hasPermission name="bsbFirm:update">
										                        <a class="green" href="#" onclick="javascript:goOperate('edit','${bsbFirmProduct.uuid}')" >
																	<i class="ace-icon fa fa-pencil bigger-130 "></i>编辑
																</a>
										                    </shiro:hasPermission>
										                    <shiro:hasPermission name="bsbFirm:delete">
																<c:if test="${bsbFirmProduct.delFlag==0}">
											                    	<a class="red" href="#" onclick="javascript:goOperate('del','${bsbFirmProduct.uuid}')" >
																		<i class="ace-icon fa fa-eye-slash bigger-130"></i>删除
																	</a>
										                    	</c:if>
										                    </shiro:hasPermission>
										
										                </td>
													</tr>
												</c:forEach> --%>
											</tbody>
										</table>
										<div class="row">
											<div class="col-xs-6">
												<div class="dataTables_info" id="sample-table-2_info"
													role="status" aria-live="polite">
													
													 <input type="hidden" name="pages" value="${pages}" id="pages"/>
													 
												</div>
											</div>
											<div class="col-xs-6">
												<div class="dataTables_paginate paging_simple_numbers"
													id="sample-table-2_paginate">
													<ul class="pagination">
														<%-- <li class="paginate_button <c:if test="${pageNum==1}">disabled</c:if>"
															aria-controls="sample-table-2" tabindex="0"
															id="sample-table-2_previous"><a href="#"
															onclick="goPage(1)">首页</a></li>
														<li class="paginate_button <c:if test='${pageNum==1}'>disabled</c:if>"
															aria-controls="sample-table-2" tabindex="0"
															id="sample-table-2_previous"><a href="#"
															onclick="goPage(${pageNum}-1)">上一页</a></li>
														<li class="paginate_button <c:if test='${pageNum==maxPageNum}'>disabled</c:if>" aria-controls="sample-table-2"
															tabindex="0" id="sample-table-2_previous"><a
															href="#" onclick="goPage(${pageNum}+1)">下一页</a></li>
														<li class="paginate_button <c:if test='${pageNum==maxPageNum}'>disabled</c:if>" aria-controls="sample-table-2"
															tabindex="0" id="sample-table-2_previous"><a
															href="#" onclick="goPage(${maxPageNum})">尾页</a></li> --%>
													</ul>
												</div>
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
					<!-- PAGE CONTENT ENDS -->
				</div>
				<!-- /.col -->
			</div>
			<!-- /.row -->
		</div>
		<!-- /.page-content-area -->
	</div>

</body>

<!-- basic scripts -->

<!--[if !IE]> -->
<script type="text/javascript">
	window.jQuery
			|| document
					.write("<script src='<%=request.getContextPath()%>/ace/assets/js/jquery.min.js'>"
							+ "<"+"/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='<%=request.getContextPath()%>/ace/assets/js/jquery1x.min.js'>"+"<"+"/script>");
</script>
<![endif]-->
<script type="text/javascript">
	if ('ontouchstart' in document.documentElement)
		document.write("<script src='<%=request.getContextPath()%>/ace/assets/js/jquery.mobile.custom.min.js'>"+ "<"+"/script>");
</script>

<script type="text/javascript">
	function goPage(pageNum){
		if(pageNum!=0){
			$("#pageNum").val(pageNum);
		}
		 lists();
	/* 	if(pageNum!=0){
			$("#pageNum").val(pageNum);
		}
		var myreg=/^[0-9]*$/;
		if(!myreg.test($("#pageNum").val())){
			alert("请输入有效数字！");
			$("#pageNum").val(1);
			return false;
		}
		$("#drizzt-table").submit(); */
	}
	
	function delflag(flag,uuid){
		var uurl="<%=request.getContextPath()%>/bsbFirmProduct/delflag.do";
		var uurll="<%=request.getContextPath()%>/bsbFirmProduct/del.do";
		var ur="";
		if(flag=="delflag"){
			ur=uurl;
			
		}else{
			ur=uurll;
			if(confirm("确定要删除该信息吗？删除将不能恢复！")){
        	}else{
        		return false;
        	}
		}
		
			 $.ajax({
		            //提交数据的类型 POST GET
		            type:"POST",
		            //提交的网址
		            url:ur,
		            //提交的数据     data:$('#drizzt-tables').serialize(),// 你的formid
		          //  data:$('#drizzt-tables').serialize(),
		           datatype: "json",
		          data:{
		            	"uuid":uuid
		            },
		       
		            //成功返回之后调用的函数             
		         success:function(e){
		        	 if(e.status==1){
		        		 toList();
		        	 }else if(e.status==3){
		        		 alert(e.msg);
		        	 }else{
		        		 alert("bug");
		        	 }
		        	 ShowDiv('MyDiv','fade');
	        		 $("#pp").html(e.msg);
		        	return true;    
		            }, 
		        
		            //调用出错执行的函数
		            error: function(){
		                //请求出错处理
		            }         
		         } );
		
	}
	
	function toList(){
		var pages=$("#pages").val();
		 $("#pages").attr("name","pageNum");
		 lists();
		 $("#pages").attr("name","pages");
	}
	
	
	function goOperate(operate,uuid){
		
		if(operate=="add"){
			$("#drizzt-table").attr("action", "<%=request.getContextPath()%>/bsbFirmProduct/toAdd.do");
			$("#drizzt-table").submit();
		}
		if(operate=="edit"){
			
			var val=uuid;
		
			$("#uuid").val(uuid);
			if(val==null){
                alert("请选择一条数据");
                return false;
            }else{
				$("#drizzt-table").attr("action", "<%=request.getContextPath()%>/bsbFirmProduct/toEdit.do");
				$("#drizzt-table").submit();
            }
		}
		if(operate=="del"){
			var val=$("#uuid:checked").val();
			if(val==null){
                alert("请选择一条数据");
                return false;
            }else{
            	if(confirm("确定要删除该信息吗？删除将不能恢复！")){
            		$("#drizzt-table").attr("action", "<%=request.getContextPath()%>/bsbFirmProduct/del.do");
     				$("#drizzt-table").submit();
            	}else{
            		return false;
            	}
            }
		}
		if(operate=="view"){
			var val=uuid;
			$("#uuid").val(uuid);
			if(val==null){
                alert("请选择一条数据");
                return false;
            }else{
				$("#drizzt-table").attr("action", "<%=request.getContextPath()%>/bsbFirmProduct/view.do");
				$("#drizzt-table").submit();
            }
		}
	}
	function search(){
		$("#pageNum").val(1);
		lists();
	}
	

function lists(){


	 $.ajax({
           //提交数据的类型 POST GET
           type:"GET",
           //提交的网址
           url:"<%=request.getContextPath()%>/firmProduct/list.do",
          datatype: "json",
         data: $("#drizzt-table").serialize(),
      
           //成功返回之后调用的函数             
        success:function(e){
        	
        	if(e.status!="1"){
        		alert(e.msg);
        		return false;
        	}
        	
       	var str="";
	        	for(var i=0;i<e.data.length;i++){
	        		
	        		var delFlag='';
	        		var delf='';
	        		if(e.data[i].delFlag == "0"){
						var delFlag = "显示";
						delf="隐藏";
					}else if(e.data[i].delFlag == "1"){   //(e.data[i].delFlag == '0' ? '隐藏' : e.data[i].delFlag == '1' ? '显示' : '异常')
						var delFlag = "隐藏";
						delf="显示";
					}
	        		var img=e.data[i].logImg
	        		var path="<%=request.getContextPath()%>/";
	        		var pathimg=path+"getPic/"+img;
	        		var chakan=path+"/bsbFirmProduct/"+e.data[i].uuid+"/view";
	        		var price=e.data[i].price==0?'面议':e.data[i].price;
						//状态
				        str+="<tr role='row' class='odd' align='center'>"
						
						
						+"<td>"+e.data[i].title+"</td>"
						
						 +"<td>"+price+"</td>"  
						 +"<td><img alt='' width='60px' height='30px' src="+pathimg+"></td> " 
						
						+"<td>"+e.data[i].sort+"</td>"
						+"<td>"+format(e.data[i].createDate)+"</td>"
						 
						+"<td>"+delFlag+"</td>" 
						+"<td> <shiro:hasPermission name='bsbFirmProduct:view'>"
						+" <a class='blue'  href='#' onclick=goOperate('view','"+e.data[i].uuid+"')>"
						+"<i class='ace-icon fa fa-search-plus bigger-130'></i>查看</a></shiro:hasPermission>"
	                  +"<shiro:hasPermission name='bsbFirmProduct:edit'>"
	                    +"<a class='green' href='#' onclick=goOperate('edit','"+e.data[i].uuid+"') >"   
							
						+"<i class='ace-icon fa fa-pencil bigger-130 '></i>编辑</a> </shiro:hasPermission>"	
						+"<shiro:hasPermission name='bsbFirmProduct:delflag'>"
		                   +"<a class='red' href='#' onclick=delflag('delflag','"+e.data[i].uuid+"') >"
							+"<i class='ace-icon fa fa-eye-slash bigger-130'></i>"+delf
							+"</a></shiro:hasPermission>"	
					+"<shiro:hasPermission name='bsbFirmProduct:del'>"
	                   +"<a class='red' href='#' onclick=delflag('del','"+e.data[i].uuid+"') >"
						+"<i class='ace-icon fa fa-eye-slash bigger-130'></i>删除"
						+"</a></shiro:hasPermission>"	
                    	
                    
	                +" </td></tr>"
				       
					}
	        	
	        	$(".tbody").html(str);
	        	var pagess="共 "+e.totalCount+"条数据，当前第<input type='text' id='pageNum'name='pageNum' style='width: 40px;' value="+e.pageNum+" />页&nbsp;&nbsp;"
	        	+"<input type='button' class='btn btn-sm btn-primary' onclick='goPage(0)' value='跳转'/>";
	        	$(".dataTables_info").html(pagess);
	        	var le=e.pageNum==1;
	        	var upPage=e.pageNum-1;
	        	var pa=e.pageNum==e.maxPageNum;
	        	var downPage=e.pageNum+1;
	      		if(le){
	      			var li1="<li class='paginate_button disabled'";
	      		}else{
	      			var li1="<li class='paginate_button'";
	      		}
	      		if(pa){
	      			var pa1="<li class='paginate_button disabled' aria-controls='sample-table-2'";
	      		}else{
	      			var pa1="<li class='paginate_button' aria-controls='sample-table-2'";
	      		}
	      	var li=li1+"aria-controls='sample-table-2' tabindex='0' id='sample-table-2_previous'><a href='#'"
				+"onclick='goPage(1)'>首页</a></li>"
				+li1+"aria-controls='sample-table-2' tabindex='0' id='sample-table-2_previous'><a href='#'"
				+"onclick='goPage("+upPage+")'>上一页</a></li>"
				+pa1+"tabindex='0' id='sample-table-2_previous'><a href='#' onclick=goPage("+downPage+")>下一页</a></li>"
				+pa1+"tabindex='0' id='sample-table-2_previous'><a href='#' onclick=goPage("+e.maxPageNum+")>尾页</a></li>";
				$(".pagination").html(li); 
					
				
	        	
       	return true;    
           }, 
       
           //调用出错执行的函数
           error: function(){
               //请求出错处理
        	   alert(curr);
           }         
        } );
	  
        }


</script>

<script type="text/javascript">	
function add0(m){return m<10?'0'+m:m }
		function format(shijianchuo)
			{
		//shijianchuo是整数，否则要parseInt转换
		
		var time = new Date(shijianchuo);
		var y = time.getFullYear();
		var m = time.getMonth()+1;
		var d = time.getDate();
		var h = time.getHours();
		var mm = time.getMinutes();
		var s = time.getSeconds();
		return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
		}
</script>
<script
	src="<%=request.getContextPath()%>/ace/assets/js/bootstrap.min.js"></script>

<script
	src="<%=request.getContextPath()%>/ace/assets/js/bootstrap-datepicker.min.js"></script>
<script
	src="<%=request.getContextPath()%>/ace/assets/locales/bootstrap-datepicker.zh-CN.min.js"></script>
	<script type="text/javascript">
jQuery(function($) {
	$("#datepicker").datepicker({
		dateFormat: "yy-mm-dd",
	    todayBtn: "linked",
	    clearBtn: true,
	    language: "zh-CN",
	    autoclose: true,
	    todayHighlight: true
	});
	
})

</script>
<!-- the following scripts are used in demo only for onpage help and you don't need them -->
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/assets/css/ace.onpage-help.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/ace/docs/assets/js/themes/sunburst.css" />

</html>
